package com.diandiji.demo.controller;

import com.diandiji.demo.entity.Manager;
import com.diandiji.demo.entity.User;
import com.diandiji.demo.service.ManagerService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/manager")
public class ManagerController {

    @Resource
    private ManagerService managerService;

    // 根据管理员名称查询管理员信息
    @GetMapping("/queryManager")
    public Manager queryManagerByName(@RequestParam String managername) {
        return managerService.queryManagerByName(managername);
    }

    // 添加用户
    @PostMapping("/addUser")
    public User addUser(@RequestBody User user) {
        return managerService.addUser(user);
    }

    // 根据用户ID删除用户
    @DeleteMapping("/deleteUser/{userID}")
    public String deleteUserByID(@PathVariable int userID) {
        managerService.deleteUserByID(userID);
        return "删除用户成功，用户ID：" + userID;
    }

    // 查询所有用户信息（返回字符串形式）
    @GetMapping("/queryAllUser")
    public String queryAllUser() {
        return managerService.queryAllUser();
    }
}
